global class CreateHCPCallCorverAndFrequency implements schedulable{

    global void execute(schedulablecontext sc){
   
        if(System.today().day()==1)
        {
            String mon;
            String year; 
            
            if(date.today().month() != 1){
              mon = string.valueof(date.today().month() - 1);
              
              year = string.valueof(date.today().year());
            }
            else
            {
              mon = '12';
              year = string.valueof(date.today().year() - 1);
            }
            if(integer.valueof(mon)<10){
            mon = '0'+ mon;
            }         
            
            CreateHCPCallCorverAndFrequencyBatchCall run = new CreateHCPCallCorverAndFrequencyBatchCall();
            run.stringSql = 'Select ownerid,Class_C_Call__c, Class_B_Call__c, Class_A_Call__c,Class_RKOL_Call__c, Class_NKOL_Call__c, Class_D_Call__c,'+ 
                'Class_DM_Call_NEW__c,salescityID__c,linemanager__c, C_Number__c, B_Number__c, A_Number__c,D_Number__c,'+
                'DM_Number__c,NKOL_Number__c,RKOL_Number__c From Call_Report_del__c where Month__c =\''+ mon + '\'and year__c =\''+ year+'\'';
      
            Database.executeBatch(run);
        }
        else//处理报表的数据
        {
            TradeDashboardLastActualBatchClass trade=new TradeDashboardLastActualBatchClass();
            Database.executeBatch(trade);
        }
    }
}